/*  1:   */ package tt.dz.web.controller.financial;
/*  2:   */ 
/*  3:   */ import com.alibaba.fastjson.JSON;
/*  4:   */ import java.util.ArrayList;
/*  5:   */ import java.util.List;
/*  6:   */ import javax.annotation.Resource;
/*  7:   */ import javax.servlet.http.HttpServletRequest;
/*  8:   */ import javax.servlet.http.HttpServletResponse;
/*  9:   */ import org.springframework.stereotype.Controller;
/* 10:   */ import org.springframework.web.bind.annotation.RequestMapping;
/* 11:   */ import org.springframework.web.bind.annotation.ResponseBody;
/* 12:   */ import tt.dz.biz.service.financial.CostServiceMerchantService;
/* 13:   */ import tt.dz.common.LogUtil;
/* 14:   */ import tt.dz.vo.CostServiceMerchantVO;
/* 15:   */ import tt.dz.vo.ResponseModle;
/* 16:   */ 
/* 17:   */ @Controller
/* 18:   */ public class CostServiceMerchantController
/* 19:   */ {
/* 20:   */   @Resource(name="costServiceMerchantService")
/* 21:   */   private CostServiceMerchantService costServiceMerchantService;
/* 22:   */   
/* 23:   */   @RequestMapping(value={"/listAllCostServiceMerchant"}, produces={"application/json;charset=UTF-8"})
/* 24:   */   @ResponseBody
/* 25:   */   public String listAllCostServiceMerchant()
/* 26:   */   {
/* 27:30 */     ResponseModle responseModle = null;
/* 28:   */     try
/* 29:   */     {
/* 30:32 */       List<CostServiceMerchantVO> serviceMerchantList = this.costServiceMerchantService.listAllCostServiceMerchant();
/* 31:33 */       responseModle = new ResponseModle("success", serviceMerchantList);
/* 32:   */     }
/* 33:   */     catch (Exception e)
/* 34:   */     {
/* 35:35 */       LogUtil.error("查询代收成本服务对应的虚拟运营商标异常", e);
/* 36:36 */       responseModle = new ResponseModle("error", new ArrayList());
/* 37:   */     }
/* 38:38 */     return JSON.toJSONString(responseModle);
/* 39:   */   }
/* 40:   */   
/* 41:   */   @RequestMapping(value={"/modifyCostServiceMerchant"}, produces={"application/json;charset=UTF-8"})
/* 42:   */   @ResponseBody
/* 43:   */   public String modifyCostServiceMerchant(HttpServletRequest request, HttpServletResponse response)
/* 44:   */   {
/* 45:50 */     ResponseModle responseModle = null;
/* 46:   */     try
/* 47:   */     {
/* 48:52 */       String modifyType = request.getParameter("modifyType");
/* 49:   */       
/* 50:54 */       CostServiceMerchantVO costServiceMerchantVO = (CostServiceMerchantVO)JSON.parseObject(request.getParameter("costServiceMerchantVO"), CostServiceMerchantVO.class);
/* 51:55 */       if (costServiceMerchantVO.getIsValid().intValue() == 1)
/* 52:   */       {
/* 53:56 */         String checkR = checkCostServiceMerchant(costServiceMerchantVO);
/* 54:57 */         if (!checkR.equals("success"))
/* 55:   */         {
/* 56:58 */           responseModle = new ResponseModle("error", checkR);
/* 57:59 */           return JSON.toJSONString(responseModle);
/* 58:   */         }
/* 59:   */       }
/* 60:62 */       if ("insert".equals(modifyType)) {
/* 61:63 */         this.costServiceMerchantService.insertCostServiceMerchant(costServiceMerchantVO);
/* 62:64 */       } else if ("update".equals(modifyType)) {
/* 63:65 */         this.costServiceMerchantService.updateCostServiceMerchant(costServiceMerchantVO);
/* 64:   */       }
/* 65:67 */       responseModle = new ResponseModle("success", null);
/* 66:   */     }
/* 67:   */     catch (Exception e)
/* 68:   */     {
/* 69:69 */       LogUtil.error("更改代收成本服务对应的虚拟运营商标异常", e);
/* 70:70 */       responseModle = new ResponseModle("error", "更改代收成本服务对应的虚拟运营商标异常");
/* 71:   */     }
/* 72:72 */     return JSON.toJSONString(responseModle);
/* 73:   */   }
/* 74:   */   
/* 75:   */   private String checkCostServiceMerchant(CostServiceMerchantVO costServiceMerchantVO)
/* 76:   */   {
/* 77:77 */     String ret = "success";
/* 78:   */     
/* 79:79 */     CostServiceMerchantVO condition = new CostServiceMerchantVO();
/* 80:80 */     condition.setServiceNo(costServiceMerchantVO.getServiceNo());
/* 81:81 */     condition.setIsValid(Integer.valueOf(1));
/* 82:   */     
/* 83:   */ 
/* 84:84 */     List<CostServiceMerchantVO> validMerchantList = this.costServiceMerchantService.getCostServiceMerchantByCondition(condition);
/* 85:85 */     if (validMerchantList.size() > 0) {
/* 86:86 */       ret = "此服务已存在有效的合作商";
/* 87:   */     }
/* 88:89 */     return ret;
/* 89:   */   }
/* 90:   */ }


/* Location:           F:\work\pengyu\mainServer\WEB-INF\classes\
 * Qualified Name:     tt.dz.web.controller.financial.CostServiceMerchantController
 * JD-Core Version:    0.7.0.1
 */